Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(metrics): add internal rpc metrics #618

Merged
merged 2 commits into from
Feb 23, 2024
Merged

Conversation

0xfourzerofour
Copy link
Collaborator

Closes #588

Proposed Changes

  • Create a middleware to wrap the json rpc client. This will be invoked whenever the Provider is used inside rundler.
  • Move provider creation to the provider/ethers module

Copy link

codecov bot commented Feb 22, 2024

Codecov Report

Attention: Patch coverage is 0% with 102 lines in your changes are missing coverage. Please review.

Project coverage is 57.25%. Comparing base (475b47d) to head (0e59b6f).

Additional details and impacted files

Impacted file tree graph

Files Coverage Δ
crates/utils/src/eth.rs 28.57% <ø> (+15.52%) ⬆️
crates/rpc/src/task.rs 0.00% <0.00%> (ø)
crates/pool/src/task.rs 0.00% <0.00%> (ø)
crates/builder/src/task.rs 0.00% <0.00%> (ø)
crates/provider/src/ethers/provider.rs 0.00% <0.00%> (ø)
crates/provider/src/ethers/metrics_middleware.rs 0.00% <0.00%> (ø)
Flag Coverage Δ
unit-tests 57.25% <0.00%> (-0.22%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
rundler binary 0.00% <ø> (ø)
builder 51.33% <0.00%> (-0.04%) ⬇️
dev 0.00% <ø> (ø)
pool 64.79% <0.00%> (-0.03%) ⬇️
provider 0.40% <0.00%> (-0.10%) ⬇️
rpc 34.72% <0.00%> (ø)
sim 84.46% <ø> (ø)
tasks ∅ <ø> (∅)
types 86.82% <ø> (ø)
utils 16.79% <ø> (+1.43%) ⬆️

crates/pool/src/task.rs Outdated Show resolved Hide resolved
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use tokio::time::Instant;

#[derive(Display, Deserialize)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need Display? Confused why we need serde and display on these enums, which one does the metrics library use?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im pretty sure the Display macro still needs to be there if we want the auto to_string implemented without having to manually implement fmt::Display for Enum

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then what is serde used for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

serde is For Serializing and Deserializing back and for from rust data types to usable structures like json and yaml. But from what I understand if you want to_string you need to implement Display. The reason we need both here is because the container attribute need to access the Deserializer from the derive. Well at least thats what I think but when I remove it, it gives an error

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should be able to remove both Deserialize and #[serde(...)], I don't see that being used anywhere. Display is being used for to_string() and you can add back that #[display(style = "lowercase")] if you want to lowercase (maybe use snake case?) the enums

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeh that its true, I have just changed

Copy link
Collaborator

@dancoombs dancoombs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! This will be huge for observability

@0xfourzerofour 0xfourzerofour merged commit a5cde2d into main Feb 23, 2024
7 checks passed
@0xfourzerofour 0xfourzerofour deleted the josh/ethers-metrics branch February 23, 2024 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add metrics to ethers-rs network requests
2 participants